<template>
	<view>
		<view class="m-list">
			<view class="m-item" v-for="(item,index) in list" :key="index" @click="selectItemFun(item)">
				<view class="m-item-edit" @click.stop="to_link('/pages2/hotel-contact-add/hotel-contact-add?id='+item.id)">
					<image src="../static/shop/edit.png" mode=""></image>
				</view>
				<view class="m-item-content">
					<view class="m-item-font1">
						<text>{{item.name}}</text>
					</view>
					<view class="m-item-font2">
						<text>{{item.phone}}</text>
					</view>
				</view>
				<view class="m-item-radio">
					<image src="../static/hotel/radio.png" mode=""></image>
					<!-- <image src="../static/hotel/radio-select.png" mode=""></image> -->
				</view>
			</view>
		</view>
		
		<view class="m-empty" v-if="loading == 'noMore' && list.length ==0">
			<image src="../static/hotel/concats-empty.png" mode=""></image>
			<text>暂无联系人</text>
		</view>
		
		<view class="m-bottom">
			<view class="m-bottom-btn" @click="to_link('/pages2/hotel-contact-add/hotel-contact-add')">
				<image src="../static/hotel/contact-add.png" mode=""></image>
				<text>新增联系人</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type:'default',
				page:1,
				loading:'loading',
				list:[],
			}
		},
		onLoad(opt) {
			this.type = opt.type || 'default'
		},
		onShow() {
			this.page = 1
			this.list = []
			this.getListFun()
		},
		onReachBottom() {
			if(this.loading == 'loading' || this.loading == 'noMore') return false;
			this.getListFun()
		},
		methods: {
			selectItemFun(item){
				if(this.type != 'default'){
					uni.$emit('selectContactEmit',item)
					this.to_back()
				}
			},
			getListFun(){
				this.$http.getJson('userAddress_lists',{page:this.page,pagenum:20,type:1}).then(res=>{
					if(res.code == 1){
						let list = res.data || []
						let len = list.length
						if(len > 0){
							this.list = this.list.concat(list)
						}
						if(len == 20){
							this.loading = 'more'
							this.page += 1
						}else{
							this.loading = 'noMore'
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
page{
	background: #f6f6f6;
}
.m-list{
	padding-top: 20rpx;
	padding-bottom: 300rpx;
	.m-item{
		display: flex;
		align-items: center;
		background: #fff;
		padding: 28rpx 25rpx;
		margin-bottom: 20rpx;
		.m-item-edit{
			display: flex;
			align-items: center;
			width: 90rpx;
			image{
				width: 30rpx;
				height: 30rpx;
			}
		}
		.m-item-content{
			flex: 1;
			.m-item-font1{
				font-size: 30rpx;
				color: #33302D;
				font-weight: 600;
				line-height: 40rpx;
			}
			.m-item-font2{
				font-size: 28rpx;
				color: #76706B;
				margin-top: 10rpx;
			}
		}
		.m-item-radio{
			display: flex;
			align-items: center;
			image{
				width: 30rpx;
				height: 30rpx;
			}
		}
	}
}

.m-empty{
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	font-size: 26rpx;
	color: #ADAAA5;
	// padding-top: 200rpx;
	image{
		width: 320rpx;
		height: 260rpx;
		margin-bottom: 30rpx;
	}
}

.m-bottom{
	position: fixed;
	bottom: 150rpx;
	width: 750rpx;
	display: flex;
	justify-content: center;
	.m-bottom-btn{
		display: flex;
		align-items: center;
		justify-content: center;
		width: 702rpx;
		height: 104rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		font-size: 30rpx;
		color: #D3A358;
		font-weight: 600;
		image{
			width: 36rpx;
			height: 36rpx;
			margin-right: 12rpx;
		}
	}
}
</style>
